summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/test/election/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/apps/test/election/src/main')
-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
7 files changed, 0 insertions, 327 deletions
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>