Rename L2 load balancer to port load balancer

CLI commands are also renamed to plbs, plb-add and plb-remove

Change-Id: I4c26b390acc5a961594a1dca92a76bee2148c090
diff --git a/apps/l2lb/BUCK b/apps/l2lb/BUCK
deleted file mode 100644
index d293b2d..0000000
--- a/apps/l2lb/BUCK
+++ /dev/null
@@ -1,23 +0,0 @@
-COMPILE_DEPS = [
-    '//lib:CORE_DEPS',
-    '//lib:KRYO',
-    '//cli:onos-cli',
-    '//core/store/serializers:onos-core-serializers',
-]
-
-TEST_DEPS = [
-    '//lib:TEST_ADAPTERS',
-]
-
-osgi_jar_with_tests (
-    deps = COMPILE_DEPS,
-    test_deps = TEST_DEPS,
-)
-
-onos_app (
-    app_name = 'org.onosproject.l2lb',
-    category = 'Utilities',
-    description = 'L2 Load Balance Service',
-    title = 'L2 Load Balance Service',
-    url = 'http://onosproject.org',
-)
diff --git a/apps/l2lb/BUILD b/apps/l2lb/BUILD
deleted file mode 100644
index f02e2f8..0000000
--- a/apps/l2lb/BUILD
+++ /dev/null
@@ -1,19 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + KRYO + CLI + [
-    "//core/store/serializers:onos-core-serializers",
-]
-
-TEST_DEPS = TEST_ADAPTERS
-
-osgi_jar_with_tests(
-    karaf_command_packages = ["org.onosproject.l2lb.cli"],
-    test_deps = TEST_DEPS,
-    deps = COMPILE_DEPS,
-)
-
-onos_app(
-    app_name = "org.onosproject.l2lb",
-    category = "Utilities",
-    description = "L2 Load Balance Service",
-    title = "L2 Load Balance Service",
-    url = "http://onosproject.org",
-)
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 603684f..0000000
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/app/L2LbManager.java
+++ /dev/null
@@ -1,601 +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.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.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-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 = {
-        L2LbService.class,
-        L2LbAdminService.class
-    }
-)
-public class L2LbManager implements L2LbService, L2LbAdminService {
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY)
-    private CoreService coreService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY)
-    private StorageService storageService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY)
-    private FlowObjectiveService flowObjService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY)
-    private MastershipService mastershipService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY)
-    private LeadershipService leadershipService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY)
-    private ClusterService clusterService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY)
-    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 98f6886..0000000
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/L2LbAddCommand.java
+++ /dev/null
@@ -1,78 +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.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-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.
- */
-@Service
-@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 doExecute() {
-        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 d14a2d0..0000000
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/L2LbListCommand.java
+++ /dev/null
@@ -1,49 +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.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-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.
- */
-@Service
-@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 doExecute() {
-        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 70920d9..0000000
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/L2LbRemoveCommand.java
+++ /dev/null
@@ -1,57 +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.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-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.
- */
-@Service
-@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 doExecute() {
-        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/portloadbalancer/BUILD b/apps/portloadbalancer/BUILD
new file mode 100644
index 0000000..3b5301e
--- /dev/null
+++ b/apps/portloadbalancer/BUILD
@@ -0,0 +1,19 @@
+COMPILE_DEPS = CORE_DEPS + KRYO + CLI + [
+    "//core/store/serializers:onos-core-serializers",
+]
+
+TEST_DEPS = TEST_ADAPTERS
+
+osgi_jar_with_tests(
+    karaf_command_packages = ["org.onosproject.portloadbalancer.cli"],
+    test_deps = TEST_DEPS,
+    deps = COMPILE_DEPS,
+)
+
+onos_app(
+    app_name = "org.onosproject.portloadbalancer",
+    category = "Utilities",
+    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..ed59699
--- /dev/null
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/app/PortLoadBalancerManager.java
@@ -0,0 +1,633 @@
+/*
+ * 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.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+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 = { PortLoadBalancerService.class, PortLoadBalancerAdminService.class }
+)
+public class PortLoadBalancerManager implements PortLoadBalancerService, PortLoadBalancerAdminService {
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
+    private CoreService coreService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
+    private StorageService storageService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
+    private FlowObjectiveService flowObjService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
+    private MastershipService mastershipService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
+    private LeadershipService leadershipService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
+    private ClusterService clusterService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
+    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..7f0c124
--- /dev/null
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/cli/PortLoadBalancerAddCommand.java
@@ -0,0 +1,79 @@
+/*
+ * 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.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+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.
+ */
+@Service
+@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 doExecute() {
+        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..6850b0f
--- /dev/null
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/cli/PortLoadBalancerListCommand.java
@@ -0,0 +1,50 @@
+/*
+ * 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.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+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.
+ */
+@Service
+@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 doExecute() {
+        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..8d19a27
--- /dev/null
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/cli/PortLoadBalancerRemoveCommand.java
@@ -0,0 +1,57 @@
+/*
+ * 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.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+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.
+ */
+@Service
+@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 doExecute() {
+        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/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 de9beab..c6844a6 100644
--- a/apps/segmentrouting/app/BUILD
+++ b/apps/segmentrouting/app/BUILD
@@ -4,7 +4,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 80c1c80..7a579b2 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
@@ -33,10 +33,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;
@@ -150,7 +150,7 @@
     HostService hostService;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY)
-    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";
@@ -177,12 +177,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() {
@@ -230,17 +230,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");
     }
@@ -255,7 +255,7 @@
         deviceEventExecutor.shutdown();
         hostEventExecutor.shutdown();
         xConnectExecutor.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))
@@ -639,7 +639,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))
@@ -693,12 +693,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);
@@ -819,12 +820,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");
                 }
@@ -1246,8 +1247,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();
@@ -1259,12 +1261,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;
                 }
             }
@@ -1273,35 +1277,35 @@
         return null;
     }
 
-    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());
     }
 
 }