Search in sources :

Example 51 with ServiceDirectory

use of org.onlab.osgi.ServiceDirectory in project onos by opennetworkinglab.

the class Ofdpa2GroupHandler method init.

public void init(DeviceId deviceId, PipelinerContext context) {
    ServiceDirectory serviceDirectory = context.directory();
    this.deviceId = deviceId;
    this.flowObjectiveStore = context.store();
    this.groupService = serviceDirectory.get(GroupService.class);
    this.storageService = serviceDirectory.get(StorageService.class);
    this.nextIndex = storageService.getAtomicCounter("group-id-index-counter");
    pendingAddNextObjectives = CacheBuilder.newBuilder().expireAfterWrite(20, TimeUnit.SECONDS).removalListener((RemovalNotification<GroupKey, List<OfdpaNextGroup>> notification) -> {
        if (notification.getCause() == RemovalCause.EXPIRED && Objects.nonNull(notification.getValue())) {
            notification.getValue().forEach(ofdpaNextGrp -> fail(ofdpaNextGrp.nextObjective(), ObjectiveError.GROUPINSTALLATIONFAILED));
        }
    }).build();
    pendingRemoveNextObjectives = CacheBuilder.newBuilder().expireAfterWrite(20, TimeUnit.SECONDS).removalListener((RemovalNotification<NextObjective, List<GroupKey>> notification) -> {
        if (notification.getCause() == RemovalCause.EXPIRED) {
            fail(notification.getKey(), ObjectiveError.GROUPREMOVALFAILED);
        }
    }).build();
    pendingGroups = CacheBuilder.newBuilder().expireAfterWrite(20, TimeUnit.SECONDS).removalListener((RemovalNotification<GroupKey, Set<GroupChainElem>> notification) -> {
        if (notification.getCause() == RemovalCause.EXPIRED) {
            log.error("Unable to install group with key {} and pending GCEs: {}", notification.getKey(), notification.getValue());
        }
    }).build();
    pendingUpdateNextObjectives = new ConcurrentHashMap<>();
    GroupChecker groupChecker = new GroupChecker(this);
    groupCheckerExecutor.scheduleAtFixedRate(groupChecker, 0, 500, TimeUnit.MILLISECONDS);
    groupService.addListener(innerGroupListener);
}
Also used : ServiceDirectory(org.onlab.osgi.ServiceDirectory) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) OfdpaGroupHandlerUtility.l2MulticastGroupKey(org.onosproject.driver.pipeline.ofdpa.OfdpaGroupHandlerUtility.l2MulticastGroupKey) RemovalNotification(com.google.common.cache.RemovalNotification) GroupService(org.onosproject.net.group.GroupService) StorageService(org.onosproject.store.service.StorageService)

Example 52 with ServiceDirectory

use of org.onlab.osgi.ServiceDirectory in project onos by opennetworkinglab.

the class RestconfWebResourceTest method setup.

@Before
public void setup() {
    ServiceDirectory testDirectory = new TestServiceDirectory().add(RestconfService.class, restconfService);
    setServiceDirectory(testDirectory);
}
Also used : ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) Before(org.junit.Before)

Example 53 with ServiceDirectory

use of org.onlab.osgi.ServiceDirectory in project onos by opennetworkinglab.

the class NetworkConfigWebResourceTest method setUpMocks.

/**
 * Sets up mocked config service.
 */
@Before
public void setUpMocks() {
    mockNetworkConfigService = new MockNetworkConfigService();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(NetworkConfigService.class, mockNetworkConfigService);
    setServiceDirectory(testDirectory);
}
Also used : ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) Before(org.junit.Before)

Example 54 with ServiceDirectory

use of org.onlab.osgi.ServiceDirectory in project onos by opennetworkinglab.

the class RegionsResourceTest method setupTest.

/**
 * Sets up the global values for all the tests.
 */
@Before
public void setupTest() {
    final CodecManager codecService = new CodecManager();
    codecService.activate();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(RegionService.class, mockRegionService).add(RegionAdminService.class, mockRegionAdminService).add(CodecService.class, codecService);
    setServiceDirectory(testDirectory);
}
Also used : RegionAdminService(org.onosproject.net.region.RegionAdminService) ServiceDirectory(org.onlab.osgi.ServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) TestServiceDirectory(org.onlab.osgi.TestServiceDirectory) CodecManager(org.onosproject.codec.impl.CodecManager) Before(org.junit.Before)

Aggregations

ServiceDirectory (org.onlab.osgi.ServiceDirectory)54 Before (org.junit.Before)51 TestServiceDirectory (org.onlab.osgi.TestServiceDirectory)51 CodecManager (org.onosproject.codec.impl.CodecManager)30 DeviceService (org.onosproject.net.device.DeviceService)7 CfmCodecContext (org.onosproject.cfm.CfmCodecContext)5 CodecService (org.onosproject.codec.CodecService)5 CoreService (org.onosproject.core.CoreService)3 CfmMdService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService)3 OpenstackRouterAdminService (org.onosproject.openstacknetworking.api.OpenstackRouterAdminService)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 DefaultServiceDirectory (org.onlab.osgi.DefaultServiceDirectory)2 ClusterService (org.onosproject.cluster.ClusterService)2 SoamService (org.onosproject.incubator.net.l2monitoring.soam.SoamService)2 K8sNetworkAdminService (org.onosproject.k8snetworking.api.K8sNetworkAdminService)2 GroupService (org.onosproject.net.group.GroupService)2 OpenstackNetworkAdminService (org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService)2 OpenstackSecurityGroupAdminService (org.onosproject.openstacknetworking.api.OpenstackSecurityGroupAdminService)2 RemovalNotification (com.google.common.cache.RemovalNotification)1 MetricsService (org.onlab.metrics.MetricsService)1