Search in sources :

Example 1 with DistributedPrimitivesTest

use of org.onosproject.distributedprimitives.DistributedPrimitivesTest in project onos by opennetworkinglab.

the class EventuallyConsistentMapTestCommand method doExecute.

@Override
protected void doExecute() {
    DistributedPrimitivesTest test = get(DistributedPrimitivesTest.class);
    map = test.getEcMap(name);
    if ("get".equals(operation)) {
        print(map.get(arg1));
    } else if ("put".equals(operation)) {
        map.put(arg1, arg2);
    } else if ("size".equals(operation)) {
        print("%d", map.size());
    } else if ("isEmpty".equals(operation)) {
        print("%b", map.isEmpty());
    } else if ("clear".equals(operation)) {
        map.clear();
    } else if ("remove".equals(operation)) {
        if (arg2 == null) {
            print(map.remove(arg1));
        } else {
            map.remove(arg1, arg2);
        }
    } else if ("containsKey".equals(operation)) {
        print("%b", map.containsKey(arg1));
    } else if ("containsValue".equals(operation)) {
        print("%b", map.containsValue(arg1));
    }
}
Also used : DistributedPrimitivesTest(org.onosproject.distributedprimitives.DistributedPrimitivesTest)

Example 2 with DistributedPrimitivesTest

use of org.onosproject.distributedprimitives.DistributedPrimitivesTest in project onos by opennetworkinglab.

the class DistributedLockTestCommand method doExecute.

@Override
protected void doExecute() {
    DistributedPrimitivesTest test = get(DistributedPrimitivesTest.class);
    lock = test.getLock(name);
    if ("lock".equals(operation)) {
        lock.lock();
    } else if ("tryLock".equals(operation)) {
        if (durationMillis == null) {
            print("%b", lock.tryLock().isPresent());
        } else {
            print("%b", lock.tryLock(Duration.ofMillis(durationMillis)).isPresent());
        }
    } else if ("unlock".equals(operation)) {
        lock.unlock();
    }
}
Also used : DistributedPrimitivesTest(org.onosproject.distributedprimitives.DistributedPrimitivesTest)

Example 3 with DistributedPrimitivesTest

use of org.onosproject.distributedprimitives.DistributedPrimitivesTest in project onos by opennetworkinglab.

the class LeaderElectorTestCommand method doExecute.

@Override
protected void doExecute() {
    ClusterService clusterService = get(ClusterService.class);
    DistributedPrimitivesTest test = get(DistributedPrimitivesTest.class);
    leaderElector = test.getLeaderElector(name);
    NodeId localNodeId = clusterService.getLocalNode().id();
    if ("run".equals(operation)) {
        print(leaderElector.run(topic, localNodeId));
    } else if ("withdraw".equals(operation)) {
        leaderElector.withdraw(topic);
    } else if ("show".equals(operation)) {
        print(leaderElector.getLeadership(topic));
    }
}
Also used : ClusterService(org.onosproject.cluster.ClusterService) NodeId(org.onosproject.cluster.NodeId) DistributedPrimitivesTest(org.onosproject.distributedprimitives.DistributedPrimitivesTest)

Aggregations

DistributedPrimitivesTest (org.onosproject.distributedprimitives.DistributedPrimitivesTest)3 ClusterService (org.onosproject.cluster.ClusterService)1 NodeId (org.onosproject.cluster.NodeId)1