Simon Hunt
Committed by Gerrit Code Review

Initial cut for UI topo model implementation.

- also moved existing classes down a package (to util).

Change-Id: Ie6c99ff10a3f4255795217a93f7028b5d8717d21
......@@ -63,7 +63,7 @@ import org.onosproject.net.topology.TopologyService;
import org.onosproject.ui.JsonUtils;
import org.onosproject.ui.UiConnection;
import org.onosproject.ui.UiMessageHandler;
import org.onosproject.ui.impl.topo.ServicesBundle;
import org.onosproject.ui.impl.topo.util.ServicesBundle;
import org.onosproject.ui.topo.PropertyPanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......
......@@ -37,12 +37,12 @@ import org.onosproject.net.intent.OpticalConnectivityIntent;
import org.onosproject.net.intent.OpticalPathIntent;
import org.onosproject.net.intent.PathIntent;
import org.onosproject.net.statistic.Load;
import org.onosproject.ui.impl.topo.IntentSelection;
import org.onosproject.ui.impl.topo.ServicesBundle;
import org.onosproject.ui.impl.topo.TopoIntentFilter;
import org.onosproject.ui.impl.topo.TrafficLink;
import org.onosproject.ui.impl.topo.TrafficLink.StatsType;
import org.onosproject.ui.impl.topo.TrafficLinkMap;
import org.onosproject.ui.impl.topo.util.IntentSelection;
import org.onosproject.ui.impl.topo.util.ServicesBundle;
import org.onosproject.ui.impl.topo.util.TopoIntentFilter;
import org.onosproject.ui.impl.topo.util.TrafficLink;
import org.onosproject.ui.impl.topo.util.TrafficLink.StatsType;
import org.onosproject.ui.impl.topo.util.TrafficLinkMap;
import org.onosproject.ui.topo.DeviceHighlight;
import org.onosproject.ui.topo.Highlights;
import org.onosproject.ui.topo.Highlights.Amount;
......@@ -66,7 +66,9 @@ import java.util.Timer;
import java.util.TimerTask;
import static org.onosproject.net.DefaultEdgeLink.createEdgeLink;
import static org.onosproject.ui.impl.TrafficMonitor.Mode.*;
import static org.onosproject.ui.impl.TrafficMonitor.Mode.IDLE;
import static org.onosproject.ui.impl.TrafficMonitor.Mode.RELATED_INTENTS;
import static org.onosproject.ui.impl.TrafficMonitor.Mode.SELECTED_INTENT;
/**
* Encapsulates the behavior of monitoring specific traffic patterns.
......
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ui.impl.topo.model;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A lazily-initialized Singleton that creates and maintains the UI-model
* of the network topology.
*/
public final class UiSharedTopologyModel {
private static final Logger log =
LoggerFactory.getLogger(UiSharedTopologyModel.class);
private static UiSharedTopologyModel singleton = null;
private UiSharedTopologyModel() {
// TODO: set up core model listeners and build the state of the model
}
public void register(UiTopoLayout layout) {
log.info("Registering topology layout {}", layout);
// TODO: register the view
}
public void unregister(UiTopoLayout layout) {
log.info("Unregistering topology layout {}", layout);
// TODO: unregister the view
}
/**
* Returns a reference to the Singleton UI network topology model.
*
* @return the singleton topology model
*/
public static synchronized UiSharedTopologyModel instance() {
if (singleton == null) {
log.info("Instantiating Singleton.");
singleton = new UiSharedTopologyModel();
}
return singleton;
}
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ui.impl.topo.model;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Base class for modeling the Topology View layout.
* <p>
* Note that an instance of this class will be created for each
* {@link org.onosproject.ui.impl.UiWebSocket} connection, and will contain
* the state of how the topology is laid out for the logged-in user.
*/
public class UiTopoLayout {
private final Logger log = LoggerFactory.getLogger(getClass());
private final String username;
private final UiSharedTopologyModel sharedModel;
private boolean registered = false;
/**
* Creates a new topology layout.
*/
public UiTopoLayout(String username) {
this.username = username;
this.sharedModel = UiSharedTopologyModel.instance();
}
/**
* Initializes the layout; registering with the shared model.
*/
public void init() {
if (!registered) {
sharedModel.register(this);
registered = true;
} else {
log.warn("already registered");
}
}
/**
* Destroys the layout; unregistering from the shared model.
*/
public void destroy() {
if (!registered) {
sharedModel.unregister(this);
} else {
log.warn("already unregistered");
}
}
@Override
public String toString() {
return String.format("{UiTopoLayout for user <%s>}", username);
}
}
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Server-side modeling of the Topology View.
*/
package org.onosproject.ui.impl.topo.model;
......@@ -15,6 +15,6 @@
*/
/**
* Topology resources for the ONOS GUI.
* Topology View server-side support.
*/
package org.onosproject.ui.impl.topo;
......
/*
* Copyright 2015 Open Networking Laboratory
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -12,10 +12,9 @@
* 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.ui.impl.topo;
package org.onosproject.ui.impl.topo.util;
import org.onosproject.net.intent.Intent;
import org.onosproject.ui.topo.NodeSelection;
......
/*
* Copyright 2015 Open Networking Laboratory
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -12,10 +12,9 @@
* 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.ui.impl.topo;
package org.onosproject.ui.impl.topo.util;
import org.onosproject.incubator.net.PortStatisticsService;
import org.onosproject.net.device.DeviceService;
......
/*
* Copyright 2014-2015 Open Networking Laboratory
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.ui.impl.topo;
package org.onosproject.ui.impl.topo.util;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Device;
......
/*
* Copyright 2015 Open Networking Laboratory
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -12,10 +12,9 @@
* 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.ui.impl.topo;
package org.onosproject.ui.impl.topo.util;
import org.onosproject.net.Link;
import org.onosproject.net.LinkKey;
......
/*
* Copyright 2015 Open Networking Laboratory
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -12,10 +12,9 @@
* 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.ui.impl.topo;
package org.onosproject.ui.impl.topo.util;
import org.onosproject.net.Link;
import org.onosproject.net.LinkKey;
......
/*
* Copyright 2016 Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Topology resources for the ONOS GUI.
*/
package org.onosproject.ui.impl.topo.util;