Added application ID store; both trivial and distributed variants.
diff --git a/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java b/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java
index 68b3244..b121dcb 100644
--- a/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/AbstractShellCommand.java
@@ -22,8 +22,8 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.karaf.shell.commands.Option;
import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.onlab.onos.ApplicationId;
-import org.onlab.onos.CoreService;
+import org.onlab.onos.core.ApplicationId;
+import org.onlab.onos.core.CoreService;
import org.onlab.onos.net.Annotations;
import org.onlab.osgi.DefaultServiceDirectory;
import org.onlab.osgi.ServiceNotFoundException;
diff --git a/cli/src/main/java/org/onlab/onos/cli/ApplicationIdListCommand.java b/cli/src/main/java/org/onlab/onos/cli/ApplicationIdListCommand.java
new file mode 100644
index 0000000..8acc3d2
--- /dev/null
+++ b/cli/src/main/java/org/onlab/onos/cli/ApplicationIdListCommand.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.onlab.onos.cli;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import org.apache.karaf.shell.commands.Command;
+import org.onlab.onos.core.ApplicationId;
+import org.onlab.onos.core.CoreService;
+
+import java.util.Collections;
+import java.util.List;
+
+import static com.google.common.collect.Lists.newArrayList;
+
+/**
+ * Lists application ID information.
+ */
+@Command(scope = "onos", name = "apps",
+ description = "Lists application ID information")
+public class ApplicationIdListCommand extends AbstractShellCommand {
+
+ @Override
+ protected void execute() {
+ CoreService service = get(CoreService.class);
+ List<ApplicationId> ids = newArrayList(service.getAppIds());
+ Collections.sort(ids, Comparators.APP_ID_COMPARATOR);
+
+ if (outputJson()) {
+ print("%s", json(ids));
+ } else {
+ for (ApplicationId id : ids) {
+ print("id=%d, name=%s", id.id(), id.name());
+ }
+ }
+ }
+
+ // ApplicationId
+ private JsonNode json(List<ApplicationId> ids) {
+ ObjectMapper mapper = new ObjectMapper();
+ ArrayNode result = mapper.createArrayNode();
+ for (ApplicationId id : ids) {
+ result.add(mapper.createObjectNode()
+ .put("id", id.id())
+ .put("name", id.name()));
+ }
+ return result;
+ }
+
+}
diff --git a/cli/src/main/java/org/onlab/onos/cli/Comparators.java b/cli/src/main/java/org/onlab/onos/cli/Comparators.java
index 807af27..80b31d5 100644
--- a/cli/src/main/java/org/onlab/onos/cli/Comparators.java
+++ b/cli/src/main/java/org/onlab/onos/cli/Comparators.java
@@ -18,6 +18,7 @@
*/
package org.onlab.onos.cli;
+import org.onlab.onos.core.ApplicationId;
import org.onlab.onos.cluster.ControllerNode;
import org.onlab.onos.net.Element;
import org.onlab.onos.net.ElementId;
@@ -36,6 +37,13 @@
private Comparators() {
}
+ public static final Comparator<ApplicationId> APP_ID_COMPARATOR = new Comparator<ApplicationId>() {
+ @Override
+ public int compare(ApplicationId id1, ApplicationId id2) {
+ return id1.id() - id2.id();
+ }
+ };
+
public static final Comparator<ElementId> ELEMENT_ID_COMPARATOR = new Comparator<ElementId>() {
@Override
public int compare(ElementId id1, ElementId id2) {
diff --git a/cli/src/main/java/org/onlab/onos/cli/SummaryCommand.java b/cli/src/main/java/org/onlab/onos/cli/SummaryCommand.java
index 60b9ded..b4b3e98 100644
--- a/cli/src/main/java/org/onlab/onos/cli/SummaryCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/SummaryCommand.java
@@ -20,7 +20,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.karaf.shell.commands.Command;
-import org.onlab.onos.CoreService;
+import org.onlab.onos.core.CoreService;
import org.onlab.onos.cluster.ClusterService;
import org.onlab.onos.net.device.DeviceService;
import org.onlab.onos.net.flow.FlowRuleService;
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
index 9a1c085..6918c93 100644
--- a/cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
@@ -25,7 +25,7 @@
import com.google.common.collect.Maps;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
-import org.onlab.onos.CoreService;
+import org.onlab.onos.core.CoreService;
import org.onlab.onos.cli.AbstractShellCommand;
import org.onlab.onos.cli.Comparators;
import org.onlab.onos.net.Device;
diff --git a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
index 610646b..b5752b6 100644
--- a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -37,9 +37,9 @@
</command>
<command>
<action class="org.onlab.onos.cli.MastersListCommand"/>
- <completers>
- <ref component-id="clusterIdCompleter"/>
- </completers>
+ </command>
+ <command>
+ <action class="org.onlab.onos.cli.ApplicationIdListCommand"/>
</command>
<command>