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; ...@@ -63,7 +63,7 @@ import org.onosproject.net.topology.TopologyService;
63 import org.onosproject.ui.JsonUtils; 63 import org.onosproject.ui.JsonUtils;
64 import org.onosproject.ui.UiConnection; 64 import org.onosproject.ui.UiConnection;
65 import org.onosproject.ui.UiMessageHandler; 65 import org.onosproject.ui.UiMessageHandler;
66 -import org.onosproject.ui.impl.topo.ServicesBundle; 66 +import org.onosproject.ui.impl.topo.util.ServicesBundle;
67 import org.onosproject.ui.topo.PropertyPanel; 67 import org.onosproject.ui.topo.PropertyPanel;
68 import org.slf4j.Logger; 68 import org.slf4j.Logger;
69 import org.slf4j.LoggerFactory; 69 import org.slf4j.LoggerFactory;
......
...@@ -37,12 +37,12 @@ import org.onosproject.net.intent.OpticalConnectivityIntent; ...@@ -37,12 +37,12 @@ import org.onosproject.net.intent.OpticalConnectivityIntent;
37 import org.onosproject.net.intent.OpticalPathIntent; 37 import org.onosproject.net.intent.OpticalPathIntent;
38 import org.onosproject.net.intent.PathIntent; 38 import org.onosproject.net.intent.PathIntent;
39 import org.onosproject.net.statistic.Load; 39 import org.onosproject.net.statistic.Load;
40 -import org.onosproject.ui.impl.topo.IntentSelection; 40 +import org.onosproject.ui.impl.topo.util.IntentSelection;
41 -import org.onosproject.ui.impl.topo.ServicesBundle; 41 +import org.onosproject.ui.impl.topo.util.ServicesBundle;
42 -import org.onosproject.ui.impl.topo.TopoIntentFilter; 42 +import org.onosproject.ui.impl.topo.util.TopoIntentFilter;
43 -import org.onosproject.ui.impl.topo.TrafficLink; 43 +import org.onosproject.ui.impl.topo.util.TrafficLink;
44 -import org.onosproject.ui.impl.topo.TrafficLink.StatsType; 44 +import org.onosproject.ui.impl.topo.util.TrafficLink.StatsType;
45 -import org.onosproject.ui.impl.topo.TrafficLinkMap; 45 +import org.onosproject.ui.impl.topo.util.TrafficLinkMap;
46 import org.onosproject.ui.topo.DeviceHighlight; 46 import org.onosproject.ui.topo.DeviceHighlight;
47 import org.onosproject.ui.topo.Highlights; 47 import org.onosproject.ui.topo.Highlights;
48 import org.onosproject.ui.topo.Highlights.Amount; 48 import org.onosproject.ui.topo.Highlights.Amount;
...@@ -66,7 +66,9 @@ import java.util.Timer; ...@@ -66,7 +66,9 @@ import java.util.Timer;
66 import java.util.TimerTask; 66 import java.util.TimerTask;
67 67
68 import static org.onosproject.net.DefaultEdgeLink.createEdgeLink; 68 import static org.onosproject.net.DefaultEdgeLink.createEdgeLink;
69 -import static org.onosproject.ui.impl.TrafficMonitor.Mode.*; 69 +import static org.onosproject.ui.impl.TrafficMonitor.Mode.IDLE;
70 +import static org.onosproject.ui.impl.TrafficMonitor.Mode.RELATED_INTENTS;
71 +import static org.onosproject.ui.impl.TrafficMonitor.Mode.SELECTED_INTENT;
70 72
71 /** 73 /**
72 * Encapsulates the behavior of monitoring specific traffic patterns. 74 * Encapsulates the behavior of monitoring specific traffic patterns.
......
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.ui.impl.topo.model;
18 +
19 +import org.slf4j.Logger;
20 +import org.slf4j.LoggerFactory;
21 +
22 +/**
23 + * A lazily-initialized Singleton that creates and maintains the UI-model
24 + * of the network topology.
25 + */
26 +public final class UiSharedTopologyModel {
27 +
28 + private static final Logger log =
29 + LoggerFactory.getLogger(UiSharedTopologyModel.class);
30 +
31 + private static UiSharedTopologyModel singleton = null;
32 +
33 + private UiSharedTopologyModel() {
34 + // TODO: set up core model listeners and build the state of the model
35 + }
36 +
37 + public void register(UiTopoLayout layout) {
38 + log.info("Registering topology layout {}", layout);
39 + // TODO: register the view
40 + }
41 +
42 + public void unregister(UiTopoLayout layout) {
43 + log.info("Unregistering topology layout {}", layout);
44 + // TODO: unregister the view
45 + }
46 +
47 + /**
48 + * Returns a reference to the Singleton UI network topology model.
49 + *
50 + * @return the singleton topology model
51 + */
52 + public static synchronized UiSharedTopologyModel instance() {
53 + if (singleton == null) {
54 + log.info("Instantiating Singleton.");
55 + singleton = new UiSharedTopologyModel();
56 + }
57 + return singleton;
58 + }
59 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.ui.impl.topo.model;
18 +
19 +import org.slf4j.Logger;
20 +import org.slf4j.LoggerFactory;
21 +
22 +/**
23 + * Base class for modeling the Topology View layout.
24 + * <p>
25 + * Note that an instance of this class will be created for each
26 + * {@link org.onosproject.ui.impl.UiWebSocket} connection, and will contain
27 + * the state of how the topology is laid out for the logged-in user.
28 + */
29 +public class UiTopoLayout {
30 + private final Logger log = LoggerFactory.getLogger(getClass());
31 +
32 + private final String username;
33 + private final UiSharedTopologyModel sharedModel;
34 +
35 + private boolean registered = false;
36 +
37 + /**
38 + * Creates a new topology layout.
39 + */
40 + public UiTopoLayout(String username) {
41 + this.username = username;
42 + this.sharedModel = UiSharedTopologyModel.instance();
43 + }
44 +
45 + /**
46 + * Initializes the layout; registering with the shared model.
47 + */
48 + public void init() {
49 + if (!registered) {
50 + sharedModel.register(this);
51 + registered = true;
52 + } else {
53 + log.warn("already registered");
54 + }
55 + }
56 +
57 + /**
58 + * Destroys the layout; unregistering from the shared model.
59 + */
60 + public void destroy() {
61 + if (!registered) {
62 + sharedModel.unregister(this);
63 + } else {
64 + log.warn("already unregistered");
65 + }
66 + }
67 +
68 + @Override
69 + public String toString() {
70 + return String.format("{UiTopoLayout for user <%s>}", username);
71 + }
72 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * Server-side modeling of the Topology View.
19 + */
20 +package org.onosproject.ui.impl.topo.model;
...@@ -15,6 +15,6 @@ ...@@ -15,6 +15,6 @@
15 */ 15 */
16 16
17 /** 17 /**
18 - * Topology resources for the ONOS GUI. 18 + * Topology View server-side support.
19 */ 19 */
20 package org.onosproject.ui.impl.topo; 20 package org.onosproject.ui.impl.topo;
......
1 /* 1 /*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2016 Open Networking Laboratory
3 * 3 *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License. 5 + * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at 6 + * You may obtain a copy of the License at
7 * 7 *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 * 9 *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
16 */ 15 */
17 16
18 -package org.onosproject.ui.impl.topo; 17 +package org.onosproject.ui.impl.topo.util;
19 18
20 import org.onosproject.net.intent.Intent; 19 import org.onosproject.net.intent.Intent;
21 import org.onosproject.ui.topo.NodeSelection; 20 import org.onosproject.ui.topo.NodeSelection;
......
1 /* 1 /*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2016 Open Networking Laboratory
3 * 3 *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License. 5 + * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at 6 + * You may obtain a copy of the License at
7 * 7 *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 * 9 *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
16 */ 15 */
17 16
18 -package org.onosproject.ui.impl.topo; 17 +package org.onosproject.ui.impl.topo.util;
19 18
20 import org.onosproject.incubator.net.PortStatisticsService; 19 import org.onosproject.incubator.net.PortStatisticsService;
21 import org.onosproject.net.device.DeviceService; 20 import org.onosproject.net.device.DeviceService;
......
1 /* 1 /*
2 - * Copyright 2014-2015 Open Networking Laboratory 2 + * Copyright 2016 Open Networking Laboratory
3 * 3 *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License. 5 + * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at 6 + * You may obtain a copy of the License at
7 * 7 *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 * 9 *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 */ 15 */
16 -package org.onosproject.ui.impl.topo; 16 +package org.onosproject.ui.impl.topo.util;
17 17
18 import org.onosproject.net.ConnectPoint; 18 import org.onosproject.net.ConnectPoint;
19 import org.onosproject.net.Device; 19 import org.onosproject.net.Device;
......
1 /* 1 /*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2016 Open Networking Laboratory
3 * 3 *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License. 5 + * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at 6 + * You may obtain a copy of the License at
7 * 7 *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 * 9 *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
16 */ 15 */
17 16
18 -package org.onosproject.ui.impl.topo; 17 +package org.onosproject.ui.impl.topo.util;
19 18
20 import org.onosproject.net.Link; 19 import org.onosproject.net.Link;
21 import org.onosproject.net.LinkKey; 20 import org.onosproject.net.LinkKey;
......
1 /* 1 /*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2016 Open Networking Laboratory
3 * 3 *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License. 5 + * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at 6 + * You may obtain a copy of the License at
7 * 7 *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 * 9 *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
16 */ 15 */
17 16
18 -package org.onosproject.ui.impl.topo; 17 +package org.onosproject.ui.impl.topo.util;
19 18
20 import org.onosproject.net.Link; 19 import org.onosproject.net.Link;
21 import org.onosproject.net.LinkKey; 20 import org.onosproject.net.LinkKey;
......
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/**
18 + * Topology resources for the ONOS GUI.
19 + */
20 +package org.onosproject.ui.impl.topo.util;