aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/test/distributed-primitives
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/apps/test/distributed-primitives')
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/pom.xml70
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/DistributedPrimitivesTest.java57
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/CounterTestIncrementCommand.java99
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestAddCommand.java77
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestGetCommand.java104
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestRemoveCommand.java102
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/TransactionalMapTestGetCommand.java73
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/TransactionalMapTestPutCommand.java81
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/package-info.java20
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/package-info.java20
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/src/main/resources/OSGI-INF/blueprint/shell-config.xml39
11 files changed, 0 insertions, 742 deletions
diff --git a/framework/src/onos/apps/test/distributed-primitives/pom.xml b/framework/src/onos/apps/test/distributed-primitives/pom.xml
deleted file mode 100644
index 0c303d66..00000000
--- a/framework/src/onos/apps/test/distributed-primitives/pom.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright 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.
- -->
-
-<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-distributed-primitives</artifactId>
- <packaging>bundle</packaging>
-
- <description>ONOS app to test distributed primitives</description>
-
- <properties>
- <onos.app.name>org.onosproject.distributedprimitives</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.onosproject</groupId>
- <artifactId>onos-core-dist</artifactId>
- <version>1.4.0-rc1</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/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/DistributedPrimitivesTest.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/DistributedPrimitivesTest.java
deleted file mode 100644
index f0892282..00000000
--- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/DistributedPrimitivesTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 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.distributedprimitives;
-
-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.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.slf4j.Logger;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-
-/**
- * Simple application to test distributed primitives.
- */
-@Component(immediate = true)
-public class DistributedPrimitivesTest {
-
- private final Logger log = getLogger(getClass());
-
- private static final String APP_NAME = "org.onosproject.distributedprimitives";
- private ApplicationId appId;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
-
- @Activate
- protected void activate() {
-
- log.info("Distributed-Primitives-test app started");
- appId = coreService.registerApplication(APP_NAME);
- }
-
- @Deactivate
- protected void deactivate() {
-
- log.info("Distributed-Primitives-test app Stopped");
- }
-}
diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/CounterTestIncrementCommand.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/CounterTestIncrementCommand.java
deleted file mode 100644
index d93ad78f..00000000
--- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/CounterTestIncrementCommand.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 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.distributedprimitives.cli;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.store.service.AsyncAtomicCounter;
-import org.onosproject.store.service.StorageService;
-import org.slf4j.Logger;
-
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * CLI command to increment a distributed counter.
- */
-@Command(scope = "onos", name = "counter-test-increment",
- description = "Increment a distributed counter")
-public class CounterTestIncrementCommand extends AbstractShellCommand {
-
- private final Logger log = getLogger(getClass());
-
- @Option(name = "-i", aliases = "--inMemory", description = "use in memory map?",
- required = false, multiValued = false)
- private boolean inMemory = false;
-
- @Option(name = "-g", aliases = "--getFirst", description = "get the counter's value before adding",
- required = false, multiValued = false)
- private boolean getFirst = false;
-
- @Argument(index = 0, name = "counter",
- description = "Counter name",
- required = true, multiValued = false)
- String counter = null;
-
- @Argument(index = 1, name = "delta",
- description = "Long to add to the counter",
- required = false, multiValued = false)
- Long delta = null;
-
- AsyncAtomicCounter atomicCounter;
-
-
- @Override
- protected void execute() {
- StorageService storageService = get(StorageService.class);
- if (inMemory) {
- atomicCounter = storageService.atomicCounterBuilder()
- .withName(counter)
- .withPartitionsDisabled()
- .buildAsyncCounter();
- } else {
- atomicCounter = storageService.atomicCounterBuilder()
- .withName(counter)
- .buildAsyncCounter();
- }
- CompletableFuture<Long> result;
- if (delta != null) {
- if (getFirst) {
- result = atomicCounter.getAndAdd(delta);
- } else {
- result = atomicCounter.addAndGet(delta);
- }
- } else {
- if (getFirst) {
- result = atomicCounter.getAndIncrement();
- } else {
- result = atomicCounter.incrementAndGet();
- }
- }
- try {
- print("%s was updated to %d", counter, result.get(3, TimeUnit.SECONDS));
- } catch (InterruptedException e) {
- return;
- } catch (ExecutionException | TimeoutException e) {
- print("Error executing command");
- log.error("Error executing command counter-test-increment", e);
- }
- }
-}
diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestAddCommand.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestAddCommand.java
deleted file mode 100644
index 2d1aa0b8..00000000
--- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestAddCommand.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 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.distributedprimitives.cli;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-
-import java.util.Arrays;
-import java.util.Set;
-
-/**
- * CLI command to add elements to a distributed set.
- */
-@Command(scope = "onos", name = "set-test-add",
- description = "Add to a distributed set")
-public class SetTestAddCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "setName",
- description = "set name",
- required = true, multiValued = false)
- String setName = null;
-
- @Argument(index = 1, name = "values",
- description = "Value(s) to add to the set",
- required = true, multiValued = true)
- String[] values = null;
-
- Set<String> set;
-
-
- Serializer serializer = Serializer.using(
- new KryoNamespace.Builder().register(KryoNamespaces.BASIC).build());
-
-
- @Override
- protected void execute() {
- StorageService storageService = get(StorageService.class);
- set = storageService.<String>setBuilder()
- .withName(setName)
- .withSerializer(serializer)
- .build();
-
- // Add a single element to the set
- if (values.length == 1) {
- if (set.add(values[0])) {
- print("[%s] was added to the set %s", values[0], setName);
- } else {
- print("[%s] was already in set %s", values[0], setName);
- }
- } else if (values.length >= 1) {
- // Add multiple elements to a set
- if (set.addAll(Arrays.asList(values))) {
- print("%s was added to the set %s", Arrays.asList(values), setName);
- } else {
- print("%s was already in set %s", Arrays.asList(values), setName);
- }
- }
- }
-}
diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestGetCommand.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestGetCommand.java
deleted file mode 100644
index 74c52c16..00000000
--- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestGetCommand.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 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.distributedprimitives.cli;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-
-import java.util.Arrays;
-import java.util.Set;
-
-/**
- * CLI command to get the elements in a distributed set.
- */
-@Command(scope = "onos", name = "set-test-get",
- description = "Get the elements in a distributed set")
-public class SetTestGetCommand extends AbstractShellCommand {
-
- @Option(name = "-s", aliases = "--size", description = "Also show the size of the set?",
- required = false, multiValued = false)
- private boolean size = false;
-
- @Argument(index = 0, name = "setName",
- description = "set name",
- required = true, multiValued = false)
- String setName = null;
-
- @Argument(index = 1, name = "values",
- description = "Check if the set contains these value(s)",
- required = false, multiValued = true)
- String[] values = null;
-
- Set<String> set;
- String output = "";
-
- Serializer serializer = Serializer.using(
- new KryoNamespace.Builder().register(KryoNamespaces.BASIC).build());
-
-
- @Override
- protected void execute() {
- StorageService storageService = get(StorageService.class);
- set = storageService.<String>setBuilder()
- .withName(setName)
- .withSerializer(serializer)
- .build();
-
- // Print the set size
- if (size) {
- print("There are %d items in set %s:", set.size(), setName);
- } else {
- print("Items in set %s:", setName);
- }
- // Print the set
- if (set.isEmpty()) {
- print("[]");
- } else {
- for (String e : set.toArray(new String[set.size()])) {
- if (output.isEmpty()) {
- output += e;
- } else {
- output += ", " + e;
- }
- }
- print("[%s]", output);
- }
- // Check if given values are in the set
- if (values == null) {
- return;
- } else if (values.length == 1) {
- // contains
- if (set.contains(values[0])) {
- print("Set %s contains the value %s", setName, values[0]);
- } else {
- print("Set %s did not contain the value %s", setName, values[0]);
- }
- } else if (values.length > 1) {
- //containsAll
- if (set.containsAll(Arrays.asList(values))) {
- print("Set %s contains the the subset %s", setName, Arrays.asList(values));
- } else {
- print("Set %s did not contain the the subset %s", setName, Arrays.asList(values));
- }
- }
- }
-}
diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestRemoveCommand.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestRemoveCommand.java
deleted file mode 100644
index 1fa073f3..00000000
--- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestRemoveCommand.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 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.distributedprimitives.cli;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-
-import java.util.Arrays;
-import java.util.Set;
-
-/**
- * CLI command to remove elements from a distributed set.
- */
-@Command(scope = "onos", name = "set-test-remove",
- description = "Remove from a distributed set")
-public class SetTestRemoveCommand extends AbstractShellCommand {
-
- @Option(name = "-r", aliases = "--retain",
- description = "Only keep the given values in the set (if they already exist in the set)",
- required = false, multiValued = false)
- private boolean retain = false;
-
- @Option(name = "-c", aliases = "--clear", description = "Clear the set of all values",
- required = false, multiValued = false)
- private boolean clear = false;
-
- @Argument(index = 0, name = "setName",
- description = "set name",
- required = true, multiValued = false)
- String setName = null;
-
- @Argument(index = 1, name = "values",
- description = "Value(s) to remove from the set",
- required = false, multiValued = true)
- String[] values = null;
-
- Set<String> set;
- Serializer serializer = Serializer.using(
- new KryoNamespace.Builder().register(KryoNamespaces.BASIC).build());
-
-
- @Override
- protected void execute() {
- StorageService storageService = get(StorageService.class);
- set = storageService.<String>setBuilder()
- .withName(setName)
- .withSerializer(serializer)
- .build();
-
- if (clear) {
- set.clear();
- print("Set %s cleared", setName);
- return;
- }
-
- if (values == null) {
- print("Error executing command: No value given");
- return;
- }
-
- if (retain) { // Keep only the given values
- if (set.retainAll(Arrays.asList(values))) {
- print("%s was pruned to contain only elements of set %s", setName, Arrays.asList(values));
- } else {
- print("%s was not changed by retaining only elements of the set %s", setName, Arrays.asList(values));
- }
- } else if (values.length == 1) {
- // Remove a single element from the set
- if (set.remove(values[0])) {
- print("[%s] was removed from the set %s", values[0], setName);
- } else {
- print("[%s] was not in set %s", values[0], setName);
- }
- } else if (values.length > 1) {
- // Remove multiple elements from a set
- if (set.removeAll(Arrays.asList(values))) {
- print("%s was removed from the set %s", Arrays.asList(values), setName);
- } else {
- print("No element of %s was in set %s", Arrays.asList(values), setName);
- }
- }
- }
-}
diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/TransactionalMapTestGetCommand.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/TransactionalMapTestGetCommand.java
deleted file mode 100644
index e41ccc8d..00000000
--- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/TransactionalMapTestGetCommand.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 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.distributedprimitives.cli;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.TransactionContext;
-import org.onosproject.store.service.TransactionalMap;
-
-/**
- * CLI command to get a value associated with a specific key in a transactional map.
- */
-@Command(scope = "onos", name = "transactional-map-test-get",
- description = "Get a value associated with a specific key in a transactional map")
-public class TransactionalMapTestGetCommand extends AbstractShellCommand {
-
- @Option(name = "-i", aliases = "--inMemory", description = "use in memory map?",
- required = false, multiValued = false)
- private boolean inMemory = false;
-
- @Argument(index = 0, name = "key",
- description = "Key to get the value of",
- required = true, multiValued = false)
- private String key = null;
-
- TransactionalMap<String, String> map;
- String mapName = "Test-Map";
- Serializer serializer = Serializer.using(KryoNamespaces.BASIC);
-
- @Override
- protected void execute() {
- StorageService storageService = get(StorageService.class);
- TransactionContext context;
- if (inMemory) {
- context = storageService.transactionContextBuilder().withPartitionsDisabled().build();
- } else {
- context = storageService.transactionContextBuilder().build();
- }
- context.begin();
- try {
- map = context.getTransactionalMap(mapName, serializer);
- String response = map.get(key);
- context.commit();
-
- if (response == null) {
- print("Key %s not found.", key);
- } else {
- print("Key-value pair (%s, %s) found.", key, response);
- }
- } catch (Exception e) {
- context.abort();
- throw e;
- }
- }
-}
diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/TransactionalMapTestPutCommand.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/TransactionalMapTestPutCommand.java
deleted file mode 100644
index 0e0e44a7..00000000
--- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/TransactionalMapTestPutCommand.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 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.distributedprimitives.cli;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.TransactionContext;
-import org.onosproject.store.service.TransactionalMap;
-
-/**
- * CLI command to put a value into a transactional map.
- */
-@Command(scope = "onos", name = "transactional-map-test-put",
- description = "Put a value into a transactional map")
-public class TransactionalMapTestPutCommand extends AbstractShellCommand {
-
- @Option(name = "-i", aliases = "--inMemory", description = "use in memory map?",
- required = false, multiValued = false)
- private boolean inMemory = false;
-
- @Argument(index = 0, name = "numKeys",
- description = "Number of keys to put the value into",
- required = true, multiValued = false)
- private int numKeys = 1;
-
- @Argument(index = 1, name = "value",
- description = "Value to map with the keys in the map",
- required = true, multiValued = false)
- private String value = null;
-
- TransactionalMap<String, String> map;
- String prefix = "Key";
- String mapName = "Test-Map";
- Serializer serializer = Serializer.using(KryoNamespaces.BASIC);
-
- @Override
- protected void execute() {
- StorageService storageService = get(StorageService.class);
- TransactionContext context;
- if (inMemory) {
- context = storageService.transactionContextBuilder().withPartitionsDisabled().build();
- } else {
- context = storageService.transactionContextBuilder().build();
- }
- context.begin();
- try {
- map = context.getTransactionalMap(mapName, serializer);
- for (int i = 1; i <= numKeys; i++) {
- String key = prefix + i;
- String response = map.put(key, value);
- if (response == null) {
- print("Created Key %s with value %s.", key, value);
- } else {
- print("Put %s into key %s. The old value was %s.", value, key, response);
- }
- }
- context.commit();
- } catch (Exception e) {
- context.abort();
- throw e;
- }
- }
-}
diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/package-info.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/package-info.java
deleted file mode 100644
index 53ed8056..00000000
--- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 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.
- */
-
-/**
- * Distributed Primitives test command-line handlers.
- */
-package org.onosproject.distributedprimitives.cli;
diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/package-info.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/package-info.java
deleted file mode 100644
index 73c41818..00000000
--- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 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 with distributed primitives.
- */
-package org.onosproject.distributedprimitives;
diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/framework/src/onos/apps/test/distributed-primitives/src/main/resources/OSGI-INF/blueprint/shell-config.xml
deleted file mode 100644
index 295171d7..00000000
--- a/framework/src/onos/apps/test/distributed-primitives/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<!--
- ~ Copyright 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.
- -->
-<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.distributedprimitives.cli.CounterTestIncrementCommand"/>
- </command>
- <command>
- <action class="org.onosproject.distributedprimitives.cli.SetTestAddCommand"/>
- </command>
- <command>
- <action class="org.onosproject.distributedprimitives.cli.SetTestGetCommand"/>
- </command>
- <command>
- <action class="org.onosproject.distributedprimitives.cli.SetTestRemoveCommand"/>
- </command>
- <command>
- <action class="org.onosproject.distributedprimitives.cli.TransactionalMapTestGetCommand"/>
- </command>
- <command>
- <action class="org.onosproject.distributedprimitives.cli.TransactionalMapTestPutCommand"/>
- </command>
- </command-bundle>
-
-</blueprint>