aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/test/election
diff options
context:
space:
mode:
authorCNlucius <lukai1@huawei.com>2016-09-13 11:40:12 +0800
committerCNlucius <lukai1@huawei.com>2016-09-13 11:41:53 +0800
commitb731e2f1dd0972409b136aebc7b463dd72c9cfad (patch)
tree5107d7d80c19ad8076c2c97c2b5ef8d1cf3ab903 /framework/src/onos/apps/test/election
parentee93993458266114c29271a481ef9ce7ce621b2a (diff)
ONOSFW-171
O/S-SFC-ONOS scenario documentation Change-Id: I51ae1cf736ea24ab6680f8edca1b2bf5dd598365 Signed-off-by: CNlucius <lukai1@huawei.com>
Diffstat (limited to 'framework/src/onos/apps/test/election')
-rw-r--r--framework/src/onos/apps/test/election/pom.xml65
-rw-r--r--framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/ElectionTest.java124
-rw-r--r--framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/ElectionTestLeaderCommand.java54
-rw-r--r--framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/ElectionTestRunCommand.java39
-rw-r--r--framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/ElectionTestWithdrawCommand.java40
-rw-r--r--framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/package-info.java20
-rw-r--r--framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/package-info.java20
-rw-r--r--framework/src/onos/apps/test/election/src/main/resources/OSGI-INF/blueprint/shell-config.xml30
8 files changed, 0 insertions, 392 deletions
diff --git a/framework/src/onos/apps/test/election/pom.xml b/framework/src/onos/apps/test/election/pom.xml
deleted file mode 100644
index 7ffb0b57..00000000
--- a/framework/src/onos/apps/test/election/pom.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright 2014 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.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-apps-test</artifactId>
- <version>1.4.0-rc1</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>onos-app-election</artifactId>
- <packaging>bundle</packaging>
-
- <description>Master election test application</description>
-
- <properties>
- <onos.app.name>org.onosproject.election</onos.app.name>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-api</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <classifier>tests</classifier>
- </dependency>
-
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-cli</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- </dependency>
-
- </dependencies>
-
-</project>
diff --git a/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/ElectionTest.java b/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/ElectionTest.java
deleted file mode 100644
index b2a72075..00000000
--- a/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/ElectionTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2014-2015 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.election;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.onosproject.cluster.ClusterService;
-import org.onosproject.core.CoreService;
-import org.onosproject.cluster.ControllerNode;
-import org.onosproject.cluster.LeadershipEvent;
-import org.onosproject.cluster.LeadershipEventListener;
-import org.onosproject.cluster.LeadershipService;
-import org.onosproject.core.ApplicationId;
-
-import org.slf4j.Logger;
-
-
-/**
- * Simple application to test leadership election.
- */
-@Component(immediate = true)
-public class ElectionTest {
-
- private final Logger log = getLogger(getClass());
-
- private static final String ELECTION_APP = "org.onosproject.election";
- private ApplicationId appId;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ClusterService clusterService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected LeadershipService leadershipService;
-
- private LeadershipEventListener leadershipEventListener =
- new InnerLeadershipEventListener();
-
- private ControllerNode localControllerNode;
-
-
- @Activate
- protected void activate() {
- log.info("Election-test app started");
-
- appId = coreService.registerApplication(ELECTION_APP);
-
- localControllerNode = clusterService.getLocalNode();
-
- leadershipService.addListener(leadershipEventListener);
- }
-
- @Deactivate
- protected void deactivate() {
-
- leadershipService.withdraw(appId.name());
- leadershipService.removeListener(leadershipEventListener);
-
- log.info("Election-test app Stopped");
- }
-
- /**
- * A listener for Leadership Events.
- */
- private class InnerLeadershipEventListener
- implements LeadershipEventListener {
-
- @Override
- public void event(LeadershipEvent event) {
-
-
- if (event.type().equals(LeadershipEvent.Type.CANDIDATES_CHANGED)) {
- return;
- }
- if (!event.subject().topic().equals(appId.name())) {
- return; // Not our topic: ignore
- }
-
- //only log what pertains to us
- log.debug("Leadership Event: time = {} type = {} event = {}",
- event.time(), event.type(), event);
-
- if (!event.subject().leader().equals(
- localControllerNode.id())) {
- return; // The event is not about this instance: ignore
- }
-
- switch (event.type()) {
- case LEADER_ELECTED:
- log.info("Election-test app leader elected");
- break;
- case LEADER_BOOTED:
- log.info("Election-test app lost election");
- break;
- case LEADER_REELECTED:
- log.debug("Election-test app was re-elected");
- break;
- default:
- break;
- }
- }
- }
-
-}
diff --git a/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/ElectionTestLeaderCommand.java b/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/ElectionTestLeaderCommand.java
deleted file mode 100644
index 5b3fab3f..00000000
--- a/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/ElectionTestLeaderCommand.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2014-2015 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.election.cli;
-
-import org.onosproject.cluster.NodeId;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.cluster.LeadershipService;
-
-/**
- * CLI command to get the current leader for the Election test application.
- */
-@Command(scope = "onos", name = "election-test-leader",
- description = "Get the current leader for the Election test application")
-public class ElectionTestLeaderCommand extends AbstractShellCommand {
-
- private NodeId leader;
- private static final String ELECTION_APP = "org.onosproject.election";
-
- @Override
- protected void execute() {
- LeadershipService service = get(LeadershipService.class);
-
- //print the current leader
- leader = service.getLeader(ELECTION_APP);
- printLeader(leader);
- }
-
- /**
- * Prints the leader.
- *
- * @param leader the leader to print
- */
- private void printLeader(NodeId leader) {
- if (leader != null) {
- print("The current leader for the Election app is %s.", leader);
- } else {
- print("There is currently no leader elected for the Election app");
- }
- }
-}
diff --git a/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/ElectionTestRunCommand.java b/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/ElectionTestRunCommand.java
deleted file mode 100644
index 5ea8ceb5..00000000
--- a/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/ElectionTestRunCommand.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2014-2015 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.election.cli;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.cluster.LeadershipService;
-
-/**
- * CLI command to run for leadership of the Election test application.
- */
-@Command(scope = "onos", name = "election-test-run",
- description = "Run for leader of the Election test application")
-public class ElectionTestRunCommand extends AbstractShellCommand {
-
- private static final String ELECTION_APP = "org.onosproject.election";
-
- @Override
- protected void execute() {
- LeadershipService service = get(LeadershipService.class);
-
- service.runForLeadership(ELECTION_APP);
- //print the current leader
- print("Entering leadership elections for the Election app.");
- }
-}
diff --git a/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/ElectionTestWithdrawCommand.java b/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/ElectionTestWithdrawCommand.java
deleted file mode 100644
index 0732a1fa..00000000
--- a/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/ElectionTestWithdrawCommand.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2014-2015 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.election.cli;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.cluster.LeadershipService;
-
-/**
- * CLI command to withdraw the local node from leadership election for
- * the Election test application.
- */
-@Command(scope = "onos", name = "election-test-withdraw",
- description = "Withdraw node from leadership election for the Election test application")
-public class ElectionTestWithdrawCommand extends AbstractShellCommand {
-
- private static final String ELECTION_APP = "org.onosproject.election";
-
- @Override
- protected void execute() {
- LeadershipService service = get(LeadershipService.class);
-
- service.withdraw(ELECTION_APP);
- //print the current leader
- print("Withdrawing from leadership elections for the Election app.");
- }
-}
diff --git a/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/package-info.java b/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/package-info.java
deleted file mode 100644
index 6c366378..00000000
--- a/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/cli/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2014-2015 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.
- */
-
-/**
- * Election test command-line handlers.
- */
-package org.onosproject.election.cli;
diff --git a/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/package-info.java b/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/package-info.java
deleted file mode 100644
index fcc48894..00000000
--- a/framework/src/onos/apps/test/election/src/main/java/org/onosproject/election/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2014-2015 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.
- */
-
-/**
- * Sample application for use in various experiments.
- */
-package org.onosproject.election;
diff --git a/framework/src/onos/apps/test/election/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/framework/src/onos/apps/test/election/src/main/resources/OSGI-INF/blueprint/shell-config.xml
deleted file mode 100644
index e9f05b43..00000000
--- a/framework/src/onos/apps/test/election/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<!--
- ~ Copyright 2014 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.
- -->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
- <command>
- <action class="org.onosproject.election.cli.ElectionTestLeaderCommand"/>
- </command>
- <command>
- <action class="org.onosproject.election.cli.ElectionTestRunCommand"/>
- </command>
- <command>
- <action class="org.onosproject.election.cli.ElectionTestWithdrawCommand"/>
- </command>
- </command-bundle>
-
-</blueprint>